/*
 *  Copyright 2012 yura.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package org.opu.pc.services.beans;

import java.io.Serializable;

/**
 *
 * @author yura
 */
public class PublisherBean extends AbstractBean implements Serializable{

	private static final long serialVersionUID = 6615941838039187971L;
	
	private String secondName;
    private String lastName;
    private boolean student = true;

    public PublisherBean() {
    }

    public PublisherBean(int id, String name, String secondName, 
    		String lastName, boolean isStudent) {
        super(id, name);
        this.secondName = secondName;
        this.lastName = lastName;
        this.student = isStudent;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getSecondName() {
        return secondName;
    }

    public void setSecondName(String secondName) {
        this.secondName = secondName;
    }
    
    public boolean isStudent() {
		return student;
	}
    
    public void setStudent(boolean student) {
		this.student = student;
	}

    public String getInitials(){
        StringBuilder sb = new StringBuilder();
        if (secondName != null && !secondName.isEmpty()){
            sb.append(secondName.charAt(0)).append('.');
            if (lastName != null && !lastName.isEmpty()){
                sb.append(' ').append(lastName.charAt(0)).append('.');
            }
        }
        return sb.toString();
    }
    
    @Override
    public String getTitle() {
    	return String.valueOf(name) + ' ' + getInitials();
    };
}
